<template>
  <div>
    <Navbar appTitle="报废入库" />
    <div class="search-content wrap-apply" :style="{top: GLOBAL.currentEnvironment ? '0' : '',height: GLOBAL.currentEnvironment ? '100vh' : 'calc(100vh - 1.12rem)',paddingBottom: GLOBAL.currentEnvironment ? '0.66rem' : ''}">
      <van-cell-group style="margin-top: 0.1rem">
        <p class="label FormTit"><span></span>工单编号</p>
        <van-field
          disabled
          v-model="repairForm.orderCode"
          placeholder="请输入"
        />
        <div class="bottomLine"></div>
      </van-cell-group>
      <van-cell-group>
        <p class="label FormTit"><span></span>生产物料</p>
        <van-field disabled v-model="repairForm.goodsName" />
        <div class="bottomLine"></div>
      </van-cell-group>
      <van-cell-group>
        <p class="label FormTit"><span></span>工序</p>
        <van-field disabled v-model="repairForm.processFullName" />
        <div class="bottomLine" style="margin-top:0.01rem"></div>
      </van-cell-group>
      <van-cell-group>
        <p class="label FormTit"><span></span>批次编号</p>
        <div style="padding:0.1rem 0.16rem"><batch-production :code="repairForm.batchCode" :id="repairForm.batchId"></batch-production></div>
        <div class="bottomLine" style="margin-top:0.01rem"></div>
      </van-cell-group>
      <van-cell-group>
        <p class="label FormTit"><span></span>处理方式</p>
        <van-field disabled v-model="repairForm.handleTypeText" />
        <div class="bottomLine"></div>
      </van-cell-group>
      <van-cell-group>
        <p class="label FormTit"><span></span>处理数量</p>
        <div style="padding: 0.1rem 0.16rem;color:#c8c9cc;font-size: 0.14rem;">{{ commafy(repairForm.num) }}{{ repairForm.reportWorkUnitText}}</div>
        <!-- <van-field disabled v-model="repairForm.num" /> -->
      </van-cell-group>

      <van-cell-group style="margin-top: 0.1rem">
        <p class="label otherText">其他</p>
        <div class="bottomLine"></div>
        <p class="label">备注</p>
        <van-field
          v-model="repairForm.remark"
          rows="2"
          autosize
          label=""
          type="textarea"
          maxlength="500"
          placeholder="请输入备注"
          show-word-limit
        />
        <div class="bottomLine"></div>
      </van-cell-group>
      <van-cell-group>
        <upload
          :key="index"
          iconType="fj"
          @fileChange="fileChange"
          :fileIds="attachment"
        />
      </van-cell-group>
      <div class="search-bottoms">
        <!-- <span class="btnconfirm" @click="btnConfirm">确定</span> -->
        <van-button type="info" :loading="loadingSubmit" class="btnconfirm" loading-text="提交中..." @click="btnConfirm">提交</van-button>
      </div>
    </div>
      
  </div>
</template>
<script>
import Navbar from "@/components/navBar/navBar_right";
import upload from "@/components/upload/upload";
import { messNotQualityHandleIinfoDetailExecuteScrap } from '@/api/system'
import { commafy } from '@/utils/util'
import BatchProduction from '@/components/BatchProduction'
export default {
  name: "materialRequisitionForm", //领料单
  components: {
    upload,
    Navbar,
    BatchProduction
  },

  data() {
    return {
      commafy,
      index: "",
      attachment: "", //附件
      repairForm: {},
      loadingSubmit: false
    };
  },
  computed: {},
  mounted() {},
  created() {
    this.getDetail();
  },
  methods: {
    getDetail() {
      this.repairForm = {
        ...this.$route.query.formData,
        remark: ''
      }
      console.log(this.repairForm,'repairFormrepairForm');
    },
    fileChange(v) {
      console.log(v,'vvvvvfile');
      this.attachment = v
    },
    // 表单提交
    btnConfirm() {
      this.loadingSubmit = true
      this.repairForm.attachment = this.attachment
      messNotQualityHandleIinfoDetailExecuteScrap(this.repairForm).then(res => {
        if (res.code == 200) {
          this.$toast('报废入库成功！')
          this.$router.go(-1)
        } else {
          this.$toast(res.message)
        }
        this.loadingSubmit = false
      })
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/assets/theme.scss";
@import "@/views/workManagement/materialRequisition/materialForm.scss";
.search-bottoms {
  width: 100%;
  height: 0.5rem;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  bottom: 0px;
  padding: 0rem 0.11rem;
  box-sizing: border-box;
  font-size: 0.16rem;
  font-weight: 500;
  z-index: 9;
  .btnconfirm {
    flex: 1;
    background: #1890ff;
    box-sizing: border-box;
    height: 0.39rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0.03rem;
    color: #ffffff;
  }
}
</style>
